/*    */ package com.lmpop.trade.util;
/*    */ 
/*    */ import com.sun.image.codec.jpeg.JPEGCodec;
/*    */ import com.sun.image.codec.jpeg.JPEGImageEncoder;
/*    */ import java.awt.Color;
/*    */ import java.awt.Font;
/*    */ import java.awt.Graphics;
/*    */ import java.awt.Image;
/*    */ import java.awt.image.BufferedImage;
/*    */ import java.io.File;
/*    */ import java.io.FileOutputStream;
/*    */ import java.io.PrintStream;
/*    */ import javax.imageio.ImageIO;
/*    */ 
/*    */ public class ImgYin
/*    */ {
/*    */   public static final void pressImage(String pressImg, String targetImg)
/*    */   {
/*    */     try
/*    */     {
/* 22 */       File _file = new File(targetImg);
/* 23 */       Image src = ImageIO.read(_file);
/* 24 */       int wideth = src.getWidth(null);
/* 25 */       int height = src.getHeight(null);
/* 26 */       BufferedImage image = new BufferedImage(wideth, height, 1);
/* 27 */       Graphics g = image.createGraphics();
/* 28 */       g.drawImage(src, 0, 0, wideth, height, null);
/*    */ 
/* 30 */       File _filebiao = new File(pressImg);
/* 31 */       Image src_biao = ImageIO.read(_filebiao);
/* 32 */       int wideth_biao = src_biao.getWidth(null);
/* 33 */       int height_biao = src_biao.getHeight(null);
/* 34 */       g.drawImage(src_biao, wideth - wideth_biao, height - height_biao, wideth_biao, height_biao, null);
/*    */ 
/* 36 */       g.dispose();
/* 37 */       FileOutputStream out = new FileOutputStream(targetImg);
/* 38 */       JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
/* 39 */       encoder.encode(image);
/* 40 */       out.close();
/*    */     } catch (Exception e) {
/* 42 */       e.printStackTrace();
/*    */     }
/*    */   }
/*    */ 
/*    */   public static void pressText(String pressText, String targetImg, String fontName, int fontStyle, int color, int fontSize, int x, int y)
/*    */   {
/*    */     try
/*    */     {
/* 61 */       File _file = new File(targetImg);
/* 62 */       Image src = ImageIO.read(_file);
/* 63 */       int wideth = src.getWidth(null);
/* 64 */       int height = src.getHeight(null);
/* 65 */       BufferedImage image = new BufferedImage(wideth, height, 1);
/* 66 */       Graphics g = image.createGraphics();
/* 67 */       g.drawImage(src, 0, 0, wideth, height, null);
/* 68 */       g.setColor(Color.RED);
/* 69 */       g.setFont(new Font(fontName, fontStyle, fontSize));
/* 70 */       g.drawString(pressText, wideth - fontSize - x, height - fontSize / 2 - y);
/* 71 */       g.dispose();
/* 72 */       FileOutputStream out = new FileOutputStream(targetImg);
/* 73 */       JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
/* 74 */       encoder.encode(image);
/* 75 */       out.close();
/*    */     } catch (Exception e) {
/* 77 */       System.out.println(e);
/*    */     }
/*    */   }
/*    */ 
/*    */   public static void main(String[] args)
/*    */   {
/* 83 */     pressImage("D:/logoxiao.gif", "D:/2.jpg");
/*    */   }
/*    */ }

/* Location:           F:\电商\commons-utils.jar
 * Qualified Name:     com.lmpop.trade.util.ImgYin
 * JD-Core Version:    0.6.0
 */